#include <iostream>
#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    int h = 0;
    int w = 0;

    for (int i = 0; i < n; i++) {
        int hi, wi;
        cin >> hi >> wi;
        h = max(h, hi);
        w = max(w, wi);
    }
    cout << (h + w) * 2 << "\n";

}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
